package lesson;


import util.JDBCUTIL;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;


public class JDBCDemo5 {
    public static void main(String[] args) throws Exception {
        Connection connection = JDBCUTIL.getConnection();

        String sql = "Select * from account";

        PreparedStatement pstt = connection.prepareStatement(sql);

        ResultSet rs = pstt.executeQuery();

        ArrayList<Account> list = new ArrayList<>();
        Account account;
        while (rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String money = rs.getString("money");

            account = new Account();
            account.setId(id);
            account.setName(name);
            account.setMoney(money);

            list.add(account);
        }

        System.out.println(list);

        rs.close();
        pstt.close();
        connection.close();
    }


}
